<?php

/**
 * GeoBlock form base class.
 *
 * @method GeoBlock getObject() Returns the current form's model object
 *
 * @package    symfony
 * @subpackage form
 * @author     Francisco Calderón <fjcalderon@gmail.com>
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseGeoBlockForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'startipnum'  => new sfWidgetFormInputText(),
      'endipnum'    => new sfWidgetFormInputHidden(),
      'location_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('GeoLocation'), 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'startipnum'  => new sfValidatorInteger(),
      'endipnum'    => new sfValidatorChoice(array('choices' => array($this->getObject()->get('endipnum')), 'empty_value' => $this->getObject()->get('endipnum'), 'required' => false)),
      'location_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('GeoLocation'))),
    ));

    $this->widgetSchema->setNameFormat('geo_block[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'GeoBlock';
  }

}
